<cfcomponent name="dataList" displayName="dataList" output="false">
	<cffunction name="importAssumptive">
		<cfargument name="data">
		<cfargument name="value">
		<cfargument name="display">
		<cfargument name="delimiters">
		<cfscript>
		variables.returnData = arrayNew(1);
		variables.oJson = createObject("component", "share.objects.cfjson.json");
		if (isSimpleValue(arguments.data)) {
			if (isJson(arguments.data)) {
				return processJson(arguments.data);
			} else {
				return processList(arguments.data,arguments.delimiters);
			}
		} else if (isArray(arguments.data)) {
			return processArray(arguments.data,arguments.value,arguments.display);
		} else if (isQuery(arguments.data)) {
			return processQuery(arguments.data,arguments.value,arguments.display);
		} else if (isXmlDoc(arguments.data)) {
			return processXML(arguments.data,arguments.value,arguments.display);
		} else {
			//ERROR-- Invalid data type or something...
		}
		</cfscript>
	</cffunction>
	<cffunction name="itIsJSON" output="false" returntype="boolean" access="public">
	<cfargument name="testValue" required="true" type="any">
	<!---
	NOTE: This function does not check if it is a syntatically correct JSON string, just if it is an "attempted" JSON
	Author: Stefan.Vesterlund@gmail.com 
	--->
	<cfif NOT isSimpleValue(arguments.testValue)>
		<!--- if it is not a string, it is not JSON --->
		<cfreturn false>
	</cfif>
	<!--- remove eventual () from string (a common "invalid key" workaround") --->
	<cfset arguments.testValue=replace(arguments.testValue,'(',',','all')>
	<cfset arguments.testValue=replace(arguments.testValue,')',',','all')>	
	<cfif (left(arguments.testValue,1) is "{" OR left(arguments.testValue,2) is "[{") and (right(arguments.testValue,1) is "}" OR right(arguments.testValue,2) is "}]")>
		<cfreturn true>
	</cfif>
	<cfreturn false>
</cffunction>
<cffunction name="processJson" access="private">
	<cfargument name="data">
</cffunction>
<cffunction name="processXML" access="private" output="false">
	
</cffunction>
<cffunction name="processList" access="private" output="false">
	<cfargument name="data">
	<cfargument name="delimiters">
	<cfloop from="1" to="#listLen(arguments.data)#" index="iListItem">
		<cfset variables.returnData[iListItem] = structNew()>
		<cfset variables.returnData[iListItem].value = listGetAt(arguments.data,iListItem)>
		<cfset variables.returnData[iListItem].display = listGetAt(arguments.data,iListItem)>
	</cfloop>
	<cfreturn variables.returnData>
</cffunction>
<cffunction name="processArray" access="private" output="false">
	<cfargument name='data'>
	<cfargument name='value'>
	<cfargument name='display'>
	<cfloop from="1" to="#ArrayLen(arguments.data)#" index="iArrayItem">
		<cfif NOT isStruct(arguments.data[iArrayItem])>
			<cfset variables.returnData[iArrayItem] = structNew()>
			<cfset variables.returnData[iArrayItem].value = arguments.data[iArrayItem]>
			<cfset variables.returnData[iArrayItem].display = arguments.data[iArrayItem]>
		<cfelseif listLen(structKeyList(arguments.data[iArrayItem])) GT 1>
			<cfif arguments.value NEQ '' OR arguments.display NEQ ''>
				<cfset variables.returnData[iArrayItem] = structNew()>
				<cfset variables.returnData[iArrayItem].value = arguments.data[iArrayItem][arguments.value]>
				<cfset variables.returnData[iArrayItem].display = arguments.data[iArrayItem][arguments.display]>
			<cfelse>
				// Throw error
			</cfif>
		<cfelse>
			<cfset variables.returnData[iArrayItem] = structNew()>
			<cfset variables.returnData[iArrayItem].value = arguments.data[iArrayItem][listGetAt(structKeyList(arguments.data[iArrayItem]),1)]>
			<cfset variables.returnData[iArrayItem].display = arguments.data[iArrayItem][listGetAt(structKeyList(arguments.data[iArrayItem]),1)]>
		</cfif>
	</cfloop>
	<cfreturn variables.returnData>
</cffunction>
<cffunction name="processQuery" access="private" output="false">
	<cfargument name='data'>
	<cfargument name='value'>
	<cfargument name='display'>
	<cfif arguments.value EQ '' OR arguments.display EQ ''>
		//Throw error
	</cfif>
	<cfloop from="1" to="#arguments.data.recordCount#" index="iRecord">
		<cfset variables.returnData[iRecord] = structNew()>
		<cfset variables.returnData[iRecord].value = arguments.data[arguments.value][iRecord]>
		<cfset variables.returnData[iRecord].display = arguments.data[arguments.display][iRecord]>
	</cfloop>
	<cfreturn variables.returnData>
</cffunction>
</cfcomponent>